﻿<!DOCTYPE html >
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
		<meta name="apple-mobile-web-app-title" content="思路广惠">
		<title> </title>

		<meta content="telephone=no" name="format-detection" />

		<link rel="stylesheet" type="text/css" href="../../src/css/base.css?1.0" />
	</head>

	<body class="body-bg">
		<header class="header">
			<a href="javascript: history.go(-1);" class="head-le"><i class="iconfont icon-fanhui i2m"></i></a>
			<h1 class="header-txt">管理收货地址</h1>
		</header>
		<section class="top1rem">
			<ul id="goodsadd">

			</ul>
		</section>
		<footer class="setup-foo">
			<a href="addtheadd.html" >
				添加新地址
			</a>
		</footer>
		<script type="text/html" id="goodsadds">

			{{# if(d.PageData.length == "0"){ }}
			<div style="text-align: center;margin-top: 50%;">
				<p style="font-size: 18px;">还没有收货地址呢？亲</p>
				暂时没有相关数据
			</div>
			{{# } }} {{# for(var i = 0; i
			< d.PageData.length; i ++ ){ }} <li class="btm1rem">
				<div class="adress-cho" data-id="{{d.PageData[i].Address_ID}}">
					<div class="flexs-bw btm1rem">
						<span>{{d.PageData[i].MembersAddress_Receiver}}</span>
						<span>{{d.PageData[i].MembersAddress_Phone}}</span>
					</div>
					<p>
						收货地址： {{d.PageData[i].MembersAddress_Address}}
					</p>
				</div>
				<div class="adress-cho flexs-bw">
					<div>
						<input class="dress-dio {{# if(d.PageData[i].MembersAddress_Mark == " 1 "){ }} dress-check  {{# } }}" type="radio" data-type={{d.PageData[i].Address_ID}} name="add" />

						<span>{{# if(d.PageData[i].MembersAddress_Mark == "1"){ }} 默认地址 {{# }else{ }}   设为默认 {{# } }}  </span>
					</div>
					<div>
						<a href="addtheadd.html?typeID={{d.PageData[i].Address_ID}}"><i class="iconfont icon-shanchu"></i> 编辑 </a>
						<span class="deladd" name="deladd" data-type={{d.PageData[i].Address_ID}}><i class="iconfont icon-shanchu"></i> 删除 </span>
					</div>
				</div>
				</li>
				{{# } }}

		</script>
		<script src="http://apps.bdimg.com/libs/laytpl.js/1.1/laytpl.js"></script>
		<script src="//cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
		<script src="//cdn.bootcss.com/layer/3.0.1/mobile/layer.js"></script>
		<script src="../../src/js/all.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			 
			silks.temp(["#goodsadds", "#goodsadd"], "/WorkMembersAddress/GetAddressByMembersID", {
				MembersID: MembersID
			}, function() {

				$(document).on("click", ".dress-dio", function() {
					var AddressID = $(this).attr("data-type");
					var that = $(this);
					$.get(urls + "/WorkMembersAddress/MembersAddressSetDefault", {
						MembersID: MembersID,
						AddressID: AddressID,
						AppID: AppID,
						Token: Token
					}, function(res) {
						if(res.Return_ID == 0) {
							$(".dress-dio").removeClass("dress-check");
							$(".dress-dio").siblings().html("设为默认");
							that.addClass("dress-check");
							that.siblings().html("默认地址");
						} else {
							layers(res.Return_Mess);
						}

					});
				});
			});
			document.addEventListener("touchstart", function(e) {
				if(e.target.getAttribute("name") == "deladd") {
					var AddressID = $(e.target).attr("data-type");
					layer.open({
						content: '确定要删除地址吗？',
						shadeClose: false,
						btn: ['确定', '取消'],
						yes: function(index) {
							$.get(urls + "/WorkMembersAddress/MembersAddressDelete", {
								MembersID: MembersID,
								AddressID: AddressID,
								AppID: AppID,
								Token: Token
							}, function(res) {
								layers(res.Return_Mess, function() {
									silks.temp(["#goodsadds", "#goodsadd"], "/WorkMembersAddress/GetAddressByMembersID", {
										MembersID: MembersID
									});
								})

							})
							layer.close(index);
						},
						no: function(index, layero) {
							layer.close(index);
						}
					});
				}

			})
		</script>
		<script>
			 
//			window.history.replaceState({page : 1},"", "address.html?1");
//			window.history.pushState('', '', 'address.html');  
 
//			window.onpopstate = function (event) {
//				silks.temp(["#goodsadds", "#goodsadd"], "/WorkMembersAddress/GetAddressByMembersID", {
//					MembersID: MembersID
//				})
////				window.location.reload();
//			}
		</script>

	</body>

</html>